```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RocketMQ 批量消息处理技术指南</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma,Arial,Roboto,"Droid Sans","Helvetica Neue","Droid Sans Fallback","Heiti SC","Hiragino Sans GB",Simsun,sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
            color: white;
        }
        .code-block {
            background: #282c34;
            color: #abb2bf;
            border-radius: 8px;
            overflow-x: auto;
        }
        .highlight {
            background-color: rgba(59, 130, 246, 0.1);
            border-left: 4px solid #3b82f6;
            padding: 1rem;
            border-radius: 0 4px 4px 0;
        }
        .card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .section-divider {
            position: relative;
            height: 80px;
            overflow: hidden;
        }
        .section-divider svg {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        .tip-box {
            background-color: #f0fdf4;
            border-left: 4px solid #10b981;
        }
        .warning-box {
            background-color: #fffbeb;
            border-left: 4px solid #f59e0b;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero py-20 px-4 md:px-10 lg:px-20">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">RocketMQ <br>批量消息处理技术指南</h1>
                    <p class="text-xl opacity-90 mb-8">掌握高性能消息处理的核心技术与最佳实践</p>
                    <div class="flex space-x-4">
                        <a href="#client-batch" class="bg-white text-blue-800 px-6 py-3 rounded-lg font-medium hover:bg-blue-50 transition">客户端批量发送</a>
                        <a href="#consume-batch" class="bg-blue-700 text-white px-6 py-3 rounded-lg font-medium hover:bg-blue-800 transition">批量消费机制</a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="mermaid">
                        graph TD
                            A[生产者] -->|批量发送| B[Broker]
                            B -->|批量存储| C[(存储层)]
                            B -->|批量复制| D[从节点]
                            E[消费者] -->|批量拉取| B
                            E --> F[批量处理]
                            F --> G[批量确认]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-6xl px-4 md:px-10 lg:px-20 py-16">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                    <i class="fas fa-rocket text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">批量消息处理概述</h2>
            </div>
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <p class="text-lg text-gray-700 mb-6">批量发送消息是RocketMQ提供的一种重要优化手段，它可以显著提高消息发送的吞吐量，减少网络开销。RocketMQ支持多种批量发送方式，适用于不同的业务场景。</p>
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
                        <h3 class="text-xl font-semibold mb-4 text-blue-700 flex items-center">
                            <i class="fas fa-bolt mr-2"></i>
                            核心优势
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span>减少网络请求次数，提高吞吐量</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span>降低系统资源消耗，提高性能</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                <span>支持多种批量处理模式，灵活性高</span>
                            </li>
                        </ul>
                    </div>
                </div>
                <div>
                    <div class="code-block p-6 mb-6">
                        <pre><code class="language-java">// 批量发送示例
List&lt;Message&gt; messages = new ArrayList&lt;&gt;();
for (int i = 0; i &lt; 100; i++) {
    Message msg = new Message(
        "BatchTopic",
        "TagA",
        "OrderID" + i,
        ("Hello RocketMQ " + i).getBytes()
    );
    messages.add(msg);
}
producer.send(messages);</code></pre>
                    </div>
                    <div class="text-sm text-gray-500 flex items-center">
                        <i class="fas fa-info-circle mr-2"></i>
                        所有消息必须属于同一个Topic，且总大小不超过4MB
                    </div>
                </div>
            </div>
        </section>

        <!-- Section Divider -->
        <div class="section-divider my-16">
            <svg viewBox="0 0 1200 120" preserveAspectRatio="none" class="fill-current text-gray-100">
                <path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".25"></path>
                <path d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z" opacity=".5"></path>
                <path d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z"></path>
            </svg>
        </div>

        <!-- Client Batch Sending -->
        <section id="client-batch" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                    <i class="fas fa-paper-plane text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">客户端批量发送方法</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-indigo-700">1. 批量消息集合发送</h3>
                    <div class="code-block p-4 mb-4">
                        <pre><code class="language-java">List&lt;Message&gt; messages = new ArrayList&lt;&gt;();
// 添加消息到集合
producer.send(messages);</code></pre>
                    </div>
                    <div class="highlight">
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>通过<code>DefaultMQProducer.send(Collection&lt;Message&gt;)</code>方法发送</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>所有消息必须属于同一个Topic</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>批量消息的总大小不能超过4MB（默认限制）</span>
                            </li>
                        </ul>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-indigo-700">2. 批量消息拆分</h3>
                    <div class="code-block p-4 mb-4">
                        <pre><code class="language-java">ListSplitter splitter = new ListSplitter(messages);
while (splitter.hasNext()) {
    List&lt;Message&gt; listItem = splitter.next();
    producer.send(listItem);
}</code></pre>
                    </div>
                    <div class="highlight">
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>当批量消息超过大小限制时，需要进行拆分</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>RocketMQ提供了<code>MessageListSplitter</code>工具类</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>可以自定义拆分逻辑满足业务需求</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-indigo-700">3. 异步批量发送</h3>
                    <div class="code-block p-4 mb-4">
                        <pre><code class="language-java">producer.send(messages, new SendCallback() {
    @Override
    public void onSuccess(SendResult sendResult) {
        // 成功处理
    }
    
    @Override
    public void onException(Throwable e) {
        // 异常处理
    }
});</code></pre>
                    </div>
                    <div class="highlight">
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>结合异步发送和批量发送，性能最佳</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>适用于对实时性要求不高的场景</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>需要实现完善的回调处理逻辑</span>
                            </li>
                        </ul>
                    </div>
                </div>

                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-indigo-700">4. 消息压缩</h3>
                    <div class="code-block p-4 mb-4">
                        <pre><code class="language-java">// 设置消息压缩
message.setCompressed(true);</code></pre>
                    </div>
                    <div class="highlight">
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>在发送批量消息前进行压缩</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>减少网络传输量，提高传输效率</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>RocketMQ支持多种压缩算法</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section Divider -->
        <div class="section-divider my-16">
            <svg viewBox="0 0 1200 120" preserveAspectRatio="none" class="fill-current text-gray-100">
                <path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".25"></path>
                <path d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z" opacity=".5"></path>
                <path d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z"></path>
            </svg>
        </div>

        <!-- Batch Consuming -->
        <section id="consume-batch" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                    <i class="fas fa-inbox text-purple-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">批量消费的实现机制</h2>
            </div>

            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 text-purple-700">批量消费基本原理</h3>
                
                <div class="grid md:grid-cols-3 gap-6 mb-8">
                    <div class="card bg-white p-6 rounded-xl shadow-sm">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-purple-50 flex items-center justify-center mr-3">
                                <i class="fas fa-cloud-download-alt text-purple-500"></i>
                            </div>
                            <h4 class="text-xl font-semibold">拉取批量消息</h4>
                        </div>
                        <div class="code-block p-4 mb-4">
                            <pre><code class="language-java">consumer.setPullBatchSize(100);</code></pre>
                        </div>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-purple-500"></i>
                                <span>设置一次拉取的消息数量</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-purple-500"></i>
                                <span>默认32条，可根据需求调整</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-xl shadow-sm">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-purple-50 flex items-center justify-center mr-3">
                                <i class="fas fa-cogs text-purple-500"></i>
                            </div>
                            <h4 class="text-xl font-semibold">批量消费处理</h4>
                        </div>
                        <div class="code-block p-4 mb-4">
                            <pre><code class="language-java">consumer.registerMessageListener(
    new MessageListenerConcurrently() {
        public ConsumeConcurrentlyStatus 
        consumeMessage(List&lt;MessageExt&gt; msgs, ...) {
            // 批量处理
        }
    }
);</code></pre>
                        </div>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-purple-500"></i>
                                <span>消息以List形式传递给消费者</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-purple-500"></i>
                                <span>支持并发和顺序两种模式</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-xl shadow-sm">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-purple-50 flex items-center justify-center mr-3">
                                <i class="fas fa-check-double text-purple-500"></i>
                            </div>
                            <h4 class="text-xl font-semibold">批量确认</h4>
                        </div>
                        <div class="code-block p-4 mb-4">
                            <pre><code class="language-java">return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;</code></pre>
                        </div>
                        <ul class="text-gray-700 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-purple-500"></i>
                                <span>处理完成后一次性确认所有消息</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-purple-500"></i>
                                <span>减少与Broker的交互次数</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 text-purple-700">批量消费模式</h3>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h4 class="text-xl font-semibold mb-4 flex items-center">
                            <i class="fas fa-random text-purple-500 mr-2"></i>
                            并发批量消费
                        </h4>
                        <div class="code-block p-4 mb-4">
                            <pre><code class="language-java">consumer.setConsumeThreadMin(20);
consumer.setConsumeThreadMax(64);</code></pre>
                        </div>
                        <div class="bg-white p-4 rounded-lg tip-box">
                            <p class="flex items-start">
                                <i class="fas fa-lightbulb text-green-500 mt-1 mr-2"></i>
                                <span class="flex-1">默认消费模式，多个线程并发处理不同批次的消息，适合消息间无依赖的场景。</span>
                            </p>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="text-xl font-semibold mb-4 flex items-center">
                            <i class="fas fa-sort-amount-down text-purple-500 mr-2"></i>
                            顺序批量消费
                        </h4>
                        <div class="code-block p-4 mb-4">
                            <pre><code class="language-java">consumer.registerMessageListener(
    new MessageListenerOrderly() {
        public ConsumeOrderlyStatus 
        consumeMessage(List&lt;MessageExt&gt; msgs, ...) {
            // 顺序处理
        }
    }
);</code></pre>
                        </div>
                        <div class="bg-white p-4 rounded-lg tip-box">
                            <p class="flex items-start">
                                <i class="fas fa-lightbulb text-green-500 mt-1 mr-2"></i>
                                <span class="flex-1">保证同一队列内消息的顺序处理，适合订单状态变更等有严格顺序要求的场景。</span>
                            </p>
                        </div>
                    </div>
                </div>
            </div>

            <div>
                <h3 class="text-2xl font-semibold mb-6 text-purple-700">批量消费与重试</h3>
                
                <div class="code-block p-4 mb-4">
                    <pre><code class="language-java">@Override
public ConsumeConcurrentlyStatus consumeMessage(List&lt;MessageExt&gt; msgs, ...) {
    List&lt;MessageExt&gt; failedMsgs = new ArrayList&lt;&gt;();
    for (MessageExt msg : msgs) {
        try {
            // 处理单条消息
        } catch (Exception e) {
            failedMsgs.add(msg);
        }
    }
    
    if (failedMsgs.isEmpty()) {
        return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
    } else {
        // 记录失败消息，后续单独处理
        return ConsumeConcurrentlyStatus.RECONSUME_LATER;
    }
}</code></pre>
                </div>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="warning-box p-4 rounded-lg">
                        <h4 class="font-semibold mb-2 flex items-center">
                            <i class="fas fa-exclamation-triangle text-yellow-500 mr-2"></i>
                            注意点
                        </h4>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-yellow-500"></i>
                                <span>批量消费失败时，所有消息都会进入重试队列</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-yellow-500"></i>
                                <span>需实现消息处理状态的跟踪机制</span>
                            </li>
                        </ul>
                    </div>
                    
                    <div class="tip-box p-4 rounded-lg">
                        <h4 class="font-semibold mb-2 flex items-center">
                            <i class="fas fa-lightbulb text-green-500 mr-2"></i>
                            最佳实践
                        </h4>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-green-500"></i>
                                <span>记录失败消息ID，后续单独处理</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-circle text-xs mt-1.5 mr-2 text-green-500"></i>
                                <span>实现幂等性处理逻辑</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Performance Optimization -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 rounded-full bg-amber-100 flex items-center justify-center mr-4">
                    <i class="fas fa-tachometer-alt text-amber-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800">批量处理的性能优化建议</h2>
            </div>

            <div class="grid md:grid-cols-3 gap-8 mb-12">
                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-amber-700">批量大小优化</h3>
                    <div class="mermaid mb-4">
                        pie
                            title 批量大小建议
                            "发送批量大小" : 35
                            "消费批量大小" : 45
                            "动态调整" : 20
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-cog text-amber-500 mt-1 mr-2"></i>
                            <span><strong>发送批量大小：</strong>每批次10-100条，总大小1-2MB</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-cog text-amber-500 mt-1 mr-2"></i>
                            <span><strong>消费批量大小：</strong>32-200条，根据处理能力调整</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-cog text-amber-500 mt-1 mr-2"></i>
                            <span><strong>动态调整：</strong>根据系统负载实时优化</span>
                        </li>
                    </ul>
                </div>

                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-amber-700">内存管理优化</h3>
                    <div class="mermaid mb-4">
                        graph LR
                            A[生产者内存] --> B[消息缓存]
                            C[消费者内存] --> D[本地队列]
                            B --> E[批量发送]
                            D --> F[批量处理]
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-memory text-amber-500 mt-1 mr-2"></i>
                            <span>设置合理的生产者客户端内存大小</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-memory text-amber-500 mt-1 mr-2"></i>
                            <span>调整消费者本地缓存消息数量和大小</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-memory text-amber-500 mt-1 mr-2"></i>
                            <span>监控和优化GC行为</span>
                        </li>
                    </ul>
                </div>

                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-amber-700">线程模型优化</h3>
                    <div class="mermaid mb-4">
                        pie
                            title 线程配置
                            "IO密集型" : 60
                            "CPU密集型" : 30
                            "线程隔离" : 10
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-microchip text-amber-500 mt-1 mr-2"></i>
                            <span><strong>IO密集型：</strong>设置较多消费线程(20-64)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-microchip text-amber-500 mt-1 mr-2"></i>
                            <span><strong>CPU密集型：</strong>线程数接近CPU核数</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-microchip text-amber-500 mt-1 mr-2"></i>
                            <span><strong>线程隔离：</strong>不同Topic使用不同消费者组</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-amber-700">业务处理优化</h3>
                    <div class="code-block p-4 mb-4">
                        <pre><code class="language-java">// 并行处理批量消息
ExecutorService executor = Executors.newFixedThreadPool(
    Runtime.getRuntime().availableProcessors()
);
List&lt;CompletableFuture&lt;Void&gt;&gt; futures = new ArrayList&lt;&gt;();

for (MessageExt msg : msgs) {
    CompletableFuture&lt;Void&gt; future = CompletableFuture.runAsync(() -> {
        // 处理单条消息
    }, executor);
    futures.add(future);
}

CompletableFuture.allOf(
    futures.toArray(new CompletableFuture[0])
).join();
executor.shutdown();</code></pre>
                    </div>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-project-diagram text-amber-500 mt-1 mr-2"></i>
                            <span>在消费者内部并行处理批量消息</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-project-diagram text-amber-500 mt-1 mr-2"></i>
                            <span>将消息转换为批量数据库操作</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-project-diagram text-amber-500 mt-1 mr-2"></i>
                            <span>实现幂等性处理逻辑</span>
                        </li>
                    </ul>
                </div>

                <div class="card bg-white p-6 rounded-xl shadow-sm">
                    <h3 class="text-2xl font-semibold mb-4 text-amber-700">网络传输优化</h3>
                    <div class="flex items-center mb-4">
                        <div class="w-16 h-16 bg-amber-100 rounded-full flex items-center justify-center mr-4">
                            <i class="fas fa-network-wired text-amber-600 text-2xl"></i>
                        </div>
                        <div>
                            <h4 class="text-lg font-semibold">关键网络参数</h4>
                            <p class="text-sm text-gray-600">优化网络传输性能</p>
                        </div>
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-wifi text-amber-500 mt-1 mr-2"></i>
                            <span><strong>消息压缩：</strong>对大批量消息启用压缩</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-wifi text-amber-500 mt-1 mr-2"></i>
                            <span><strong>TCP缓冲区：</strong>调整socketSndBufSize和socketRcvBufSize</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-wifi text-amber-500 mt-1 mr-2"></i>
                            <span><strong>Nagle算法：</strong>对延迟敏感场景禁用Nagle</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12 px-4">
        <div class="container mx-auto max-w-6xl px-4 md:px-10 lg:px-20">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-2xl font-bold mb-2">技术小馆</h3>
                    <p class="text-gray-400">深耕技术，分享知识</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. All rights reserved.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            pie: {
                useMaxWidth: true,
                htmlLabels: true
            }
        });
    </script>
</body>
</html>
```